<script type="text/javascript" language="javascript" charset="utf-8">
$(".header-con li a").removeClass("open-menu");
$(".header-con li #statistical_datum").addClass("open-menu");
</script>
<div class="boxed clearfix">
  <div class="common-tit">
    <h2>导师数据</h2>
    <span>数据统计 > 导师数据</span>
    <div class="cours-gbtn">
      <div class="list-box">
        <div class="downbtn">
          <span>全部分店</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">全部分店</li>
          <% @studios.each do |stu| %>
            <li data_id="<%= stu.id %>"><%= stu.name %></li>
          <%end%>
        </ul>
      </div>
    </div>
  </div>
  <div class="global-data">
    <div class="xdata-box">
      <h3>导师课消排行榜</h3>
      <div id="teaData"></div>
    </div>
  </div>
</div>
<script src="/assets/js/echarts.common.min.js"></script>
<script src="/assets/js/common-list.js"></script>
<script>
var myChart = echarts.init(document.getElementById('teaData'));
var course_teacher_name_array = <%== @course_teacher_name_array %>;
var course_teacher_amount_array = <%== @course_teacher_amount_array %>;
option = {
  tooltip: {
    trigger: 'axis',
  },
  legend: {
    data: ['2011年', '2012年']
  },
  grid: {
    left: '10%',
    right: '8%',
    top: '1%',
    containLabel: false
  },
  toolbox: {
    show : true,
  },
  xAxis: {
    type: 'value',
    boundaryGap: [0, 0.01]
  },
  yAxis: {
    type : 'category',
    axisLabel:{
      interval:0,
      rotate:0,
      margin:2,
      textStyle:{
        color:"#222"
      }},
    data: course_teacher_name_array
  },
  series: [
  {
    name: '课消金额(元)',
    type: 'bar',
    data: course_teacher_amount_array
  }
  ]
};

myChart.setOption(option);
</script>
<script type="text/javascript">
  $(".cours-gbtn .list-box li").on("click", function() {
    $(this).parent().parent().find("span").attr("data_id", $(this).attr("data_id"));
    transD = $(this).attr("data_id");
    $.ajax({
      type:'get', url:"/admin/statistical_datum/change_teacher?studio_id="+ transD,
      success: function(data) {
        if (data.error) {
        // console.log("wrong");
        } 
      }
    });
  });
</script>
